<?php 
    
function list_cetak($start , $limit){
	$header = array(
		'Keterangan'=>array('style'=>'border-bottom:2px solid;width:70%'),  
		'Laki-laki'=>array('style'=>'border-bottom:2px solid;width:10%'),  
		'Perempuan'=>array('style'=>'border-bottom:2px solid;width:10%'),  
		'Jumlah'=>array('style'=>'border-bottom:2px solid;width:10%'),  
	);
	
	$query = "SELECT * FROM profil_sdm";
	$result = my_query($query);
	$row=array();
	$total=$total_laki=$total_per=0;
	while($ey = my_fetch_array($result)){
		$ket=str_repeat("&nbsp;",($ey['heading']-1)*3).$ey['label'];
		if($ey['total']=='Y'){
			$laki=$total_laki;
			$per=$total_per;
			$jumlah=$total;		
		}elseif(empty($ey['sql_statement'])){
			$laki='';
			$per='';
			$jumlah='';
		}else{
			$query = "SELECT COUNT(*) AS total FROM karyawan a 
				INNER JOIN biodata b ON a.biodata_id=b.biodata_id
				LEFT JOIN kekaryawanan c ON a.karyawan_id=c.karyawan_id 
				LEFT JOIN golongan_jabatan d ON d.golongan_jabatan_id=c.golongan_jabatan_id
				LEFT JOIN status_kekaryawanan f	ON f.status_id = e.status_kekaryawanan_id
				LEFT JOIN riwayat_pendidikan_karyawan g ON a.karyawan_id=g.karyawan_id 
				LEFT JOIN riwayat_pendidikan h ON h.riwayat_pendidikan_id=g.riwayat_pendidikan_id
				WHERE a.karyawan_id NOT IN (select karyawan_id FROM karyawan_disable)"; 
			$query .= " AND ".$ey['sql_statement'];
			$result1 = my_query($query." AND b.kelamin='laki-laki'");
			$datas = my_fetch_array($result1);		
			$laki=$datas['total'];
			$result1 = my_query($query." AND b.kelamin='perempuan'");
			$datas = my_fetch_array($result1);		
			$per=$datas['total'];			
			$jumlah=$laki+$per;
			$total_laki+=$laki;
			$total_per+=$per;
			$total+=$jumlah ;
		}
		if($ey['heading']==1){
			$row[] = array(
					'ket'=> "&nbsp;",
					'laki'=> "&nbsp;" ,
					'per'=> "&nbsp;",
					'jumlah'=> "&nbsp;",	
			);
			$total=$total_laki=$total_per=0;
		}
		$row[] = array(
				'ket'=> $ket,
				'laki'=> $laki ,
				'per'=> $per,
				'jumlah'=> $jumlah,
			);			
	}	
	
	$datas = table_cetak_rows($row);   
	return  table_cetak_builder($header , $datas ,  4, false );
} 
?>
<style type="text/css">
<!--

	table.page_header {width: 100%; border: none; background-color: #CDCDCD; border-bottom: solid 1mm #000; padding: 2mm }
	table.page_footer {width: 100%; border: none;  border-top: solid 1mm #000; padding: 2mm}
div.zone
{
	border: solid 2mm #66AACC;
	border-radius: 3mm;
	padding: 1mm;
	background-color: #FFEEEE;
	color: #440000;
}
div.zone_over
{
	width: 30mm;
	height: 35mm;
	overflow: hidden;
}

-->
</style>
<?php 
	$query = "SELECT * FROM profil_sdm";
	$result = my_query($query);
	$total = my_num_rows($result);
	$limit = 20;
	$total_page = ceil($total/$limit) -1; 
	for($i = 0; $i<=  $total_page  ;$i++):
	$start =  ( $i * $limit );
	
?>	 
<page style="font-size: 10pt">
	<page_footer>
		<table class="page_footer">
			<tr>
				<td style="width: 33%; text-align: left;">
					 HRIS RSKM 
				</td>
				<td style="width: 34%; text-align: center">
					page [[page_cu]]/[[page_nb]]
				</td>
				<td style="width: 33%; text-align: right">
					M A P &copy; 2010 - <?php echo date('Y'); ?>
				</td>
			</tr>
		</table>
	</page_footer>

	<div style="width: 100%; text-align:center; padding:2px; font-size: 13pt ;">Daftar data unit kompetensi </div>
	<?php echo list_cetak($start , $limit); ?> 
</page>
<?php endfor; ?>